/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#include "stdafx.h"
#include "视口辅助物体.h"

#include <物体/S_摄像机.h>
#include "core/shader_color.h"


static void f_基准网格_参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);

	auto& push = f_df_推送常量<S_ConstPush_Mesh_GraduationLine>(me.m_常量推送);
	push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
}

S_物体* f_辅助物体_创建基准网格(S_设备环境& ctx) {
	auto ob = f_ob_创建(ctx, E_物体类型::t_网格物体);
	ob->m_深度偏移 = -1;

	f_ob_set数据槽数量(ob, 3);

	auto& 主线 = f_ob_set数据(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 0);
	f_me_网格常量推送初始化<S_ConstPush_Mesh_GraduationLine>(主线);
	f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_网格基面, 0);

	主线.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_无顶点索引;
	主线.m_Mesh->mf_参数设置回调	= f_基准网格_参数修改;
	主线.m_Mesh->m_线宽				= 2;
	主线.m_Mesh->m_顶点数量			= 2;

	auto& push主线 = f_me_网格推送常量<S_ConstPush_Mesh_GraduationLine>(主线);
	push主线.m_CellSize = 0;
	push主线.m_Grid_HNum = 1;
	push主线.m_CameraDis = 10;

	

	auto& 基线 = f_ob_set数据(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 1);
	auto& 轴线 = f_ob_set数据(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 2);
	主线.m_深度偏移 = -1;
	基线.m_深度偏移 = -1;
	轴线.m_深度偏移 = -1;


	f_me_网格常量推送初始化<S_ConstPush_Mesh_GraduationLine>(基线);
	f_me_网格常量推送初始化<S_ConstPush_Mesh_GraduationLine>(轴线);
	

	auto* me基线 = 基线.m_Mesh;
	auto* me轴线 = 轴线.m_Mesh;

	me轴线->m_顶点数量 = 100;
	me轴线->m_绘制类型 = S_元素绘制类型::e_绘制类型_无顶点索引;
	me轴线->m_线宽 = 1.4;
	me轴线->mf_参数设置回调 = f_基准网格_参数修改;


	me基线->m_顶点数量 = 100;
	me基线->mf_参数设置回调 = f_基准网格_参数修改;
	me基线->m_绘制类型 = S_元素绘制类型::e_绘制类型_无顶点索引;
	me基线->m_线宽 = 1;




	auto& push基线 = f_df_推送常量<S_ConstPush_Mesh_GraduationLine>(基线.m_常量推送);
	push基线.m_CellSize = 1;
	push基线.m_Grid_HNum = 100;
	push基线.m_CameraDis = 10;

	auto& push轴线 = f_df_推送常量<S_ConstPush_Mesh_GraduationLine>(轴线.m_常量推送);
	push轴线.m_CellSize = 1;
	push轴线.m_Grid_HNum = 100;
	push轴线.m_CameraDis = 10;

	
	f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_网格基面, 1, 0);
	f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_网格基面, 2, 0);
	
    return ob;
}

void f_辅助物体_基准网格缩放(S_摄像机* camera) {
	
	//基准网格缩放
	vec3 eye = f_camera_get眼睛位置(*camera);
	float32 d = max(abs(eye.y), camera->m_视距);

	int exponent = static_cast<int>(std::log10(d));
	uint64_t lowerPower = std::pow(10, exponent);
	uint64_t upperPower = std::pow(10, exponent + 1);

	
	// 确定哪个候选值更接近原始值
	int32 倍数 = (d - lowerPower < upperPower - d) ? lowerPower : upperPower;

	int32 缩放跨度 = max(倍数, 1);
	float32 轴线颜色缩放 = min(d / 缩放跨度 / 5.0, 1);
	float32 颜色缩放 = 1 - 轴线颜色缩放;
	

	auto& 根线网格模型 = S_框架::g_基准网格线->m_网格模型[0];
	auto& 基线网格模型 = S_框架::g_基准网格线->m_网格模型[1];
	auto& 轴线网格模型 = S_框架::g_基准网格线->m_网格模型[2];

	根线网格模型.m_Mesh->m_顶点数量 = 2;
	基线网格模型.m_Mesh->m_顶点数量 = 100 * 10;
	轴线网格模型.m_Mesh->m_顶点数量 = 102;
	

	auto& push根线 = f_me_网格推送常量<S_ConstPush_Mesh_GraduationLine>(根线网格模型);
	push根线.m_CellSize = 0;
	push根线.m_Grid_HNum = 1;
	push根线.m_CameraDis = camera->m_视距;


	auto& push基线 = f_me_网格推送常量<S_ConstPush_Mesh_GraduationLine>(基线网格模型);
	push基线.m_CellSize = 缩放跨度 * 0.1;
	push基线.m_Grid_HNum = 基线网格模型.m_Mesh->m_顶点数量 >> 1;
	push基线.m_CameraDis = camera->m_视距;

	auto& push轴线 = f_me_网格推送常量<S_ConstPush_Mesh_GraduationLine>(轴线网格模型);
	push轴线.m_CellSize = 缩放跨度;
	push轴线.m_Grid_HNum = 轴线网格模型.m_Mesh->m_顶点数量 >> 1;
	push轴线.m_CameraDis = camera->m_视距;
	
	
	push根线.m_Ob_Color = f_PackData4X8({255,255,255, 255 });
	push基线.m_Ob_Color = f_PackData4X8({50,100,110, uint8(255.0 * ((颜色缩放)) ) });
	push轴线.m_Ob_Color = f_PackData4X8({50,100,110, uint8(255.0 * ((轴线颜色缩放 + 1) * 0.5)) });

}





static void f_辅助物体_世界方向轴参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);

	switch (多维子元素) {
		case 0: {
			auto& push = f_df_推送常量<S_ConstPush_Mesh_Line>(me.m_常量推送);
			push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
			push.m_Ob_ShaderType = 0;
			break;
		}
		case 1: {
			auto& push = f_me_网格推送常量<S_ConstPush_Mesh_Point>(me);
			push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
			push.m_PointSize = 20 * me.m_Mesh->m_线宽;
			break;
		}
		default:
			break;
	}
}

S_物体* f_辅助物体_创建世界方向轴(S_设备环境& ctx) {
	auto ob = f_ob_创建(ctx, E_物体类型::t_网格物体);
	ob->m_深度偏移 = 10;

	f_ob_set数据槽数量(ob, 2);
	auto& 轴线 = f_ob_setData<S_ConstPush_Mesh_Line>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 0);
	f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal], 0);
	

	轴线.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	轴线.m_Mesh->mf_参数设置回调	= f_辅助物体_世界方向轴参数修改;
	轴线.m_Mesh->m_线宽				= 3;

	auto& push主线 = f_me_网格推送常量<S_ConstPush_Mesh_Line>(轴线);
	

	
	std::vector<S_VNTC> 顶点;
	顶点.push_back({{0,0,0}, {}, {0,0, glsl_RGBAToFloat({255,50,100,255})}});
	顶点.push_back({{1,0,0}, {}, {0,0, glsl_RGBAToFloat({255,50,100,255})}});

	顶点.push_back({{0,0,0}, {}, {0,0, glsl_RGBAToFloat({60,255,50,255})}});
	顶点.push_back({{0,1,0}, {}, {0,0, glsl_RGBAToFloat({60,255,50,255})}});

	顶点.push_back({{0,0,0}, {}, {0,0, glsl_RGBAToFloat({50,100,255,255})}});
	顶点.push_back({{0,0,1}, {}, {0,0, glsl_RGBAToFloat({50,100,255,255})}});

	f_me_fill顶点(轴线.m_Mesh, 顶点);

	std::vector<uint32> index = {0,1, 2,3, 4,5};
	f_me_fill索引(轴线.m_Mesh, index);




	auto& 端点 = f_ob_setData<S_ConstPush_Mesh_Point>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 1);
	f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal], 1);

	端点.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
	端点.m_Mesh->mf_参数设置回调	= f_辅助物体_世界方向轴参数修改;
	端点.m_Mesh->m_线宽				= 1;

	顶点.clear();
	顶点.push_back({{1,0,0}, {}, {0,0, glsl_RGBAToFloat({255,50,100,255})}});
	顶点.push_back({{0,1,0}, {}, {0,0, glsl_RGBAToFloat({60,255,50,255})}});
	顶点.push_back({{0,0,1}, {}, {0,0, glsl_RGBAToFloat({50,100,255,255})}});
	顶点.push_back({{-1,0,0}, {}, {0,0, glsl_RGBAToFloat({255,50,100,255})}});
	顶点.push_back({{0,-1,0}, {}, {0,0, glsl_RGBAToFloat({60,255,50,255})}});
	顶点.push_back({{0,0,-1}, {}, {0,0, glsl_RGBAToFloat({50,100,255,255})}});
	f_me_fill顶点(端点.m_Mesh, 顶点);

	auto& push端点 = f_me_网格推送常量<S_ConstPush_Mesh_Point>(端点);
	push端点.m_Ob_ShaderType = DEF_FS_ShaderType_CirclePoint;
	push端点.m_PointSize = 20;



	//auto& 标识字 = f_ob_setData<S_ConstPush_Mesh_Point>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 2);
	//f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_注视牌面[E_图层混合模式::e_Normal], 2);
	//f_surface_get矢量字符网格(ctx, 'X', u"雅黑", 标识字.m_Mesh);
	//
	//端点.m_Mesh->m_绘制类型	= S_元素绘制类型::e_绘制类型_索引;
	//端点.m_Mesh->mf_参数设置回调	= f_辅助物体_世界方向轴参数修改;

	return ob;
}





static void f_变换手柄_点参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);
	auto& push = f_df_推送常量<S_ConstPush_Mesh_Point>(me.m_常量推送);
	push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
	push.m_Ob_ShaderType = f_glsl_Build_ShaderType(DEF_FS_ShaderType_CirclePoint, DEF_3DTranform_Normal);
	push.m_Ob_Color = f_PackData4X8(S_RGBA8UI{ 255, 200, 90, 255 });
	push.m_PointSize = 10;
}
static void f_变换手柄_线参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);
	auto& push = f_df_推送常量<S_ConstPush_Mesh_Line>(me.m_常量推送);
	push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
	push.m_Ob_ShaderType = f_glsl_Build_ShaderType(me.m_Mesh->m_片源着色模式, DEF_3DTranform_Normal);
}
static void f_变换手柄_面参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);
	auto& push = f_df_推送常量<S_ConstPush_Mesh_Face>(me.m_常量推送);
	push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
	push.m_Ob_ShaderType = f_glsl_Build_ShaderType(DEF_3DShaderType_PerObColor, DEF_3DTranform_Normal);
}
static void f_变换手柄_朝向视口线参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);
	auto& push = f_df_推送常量<S_ConstPush_Mesh_Line>(me.m_常量推送);
	push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
	push.m_Ob_ShaderType = f_glsl_Build_ShaderType(me.m_Mesh->m_片源着色模式, me.m_Mesh->m_顶点变换模式);
	//push.m_Ob_Color = f_PackData4X8(S_RGBA8UI{ 180, 180, 180, 255 });
}




static float32 C顶点颜色 = UintBitFloat(f_PackData4X8(S_主题颜色::uic_焦点));
static float32 R顶点颜色 = UintBitFloat(f_PackData4X8(S_主题颜色::uic_R));
static float32 G顶点颜色 = UintBitFloat(f_PackData4X8(S_主题颜色::uic_G));
static float32 B顶点颜色 = UintBitFloat(f_PackData4X8(S_主题颜色::uic_B));

static std::vector<S_网格包> g移动变换手柄网格;
static std::vector<S_网格包> g旋转变换手柄网格;
static std::vector<S_网格包> g缩放变换手柄网格;

static std::vector<S_网格包> g移动变换手柄网格_X;
static std::vector<S_网格包> g移动变换手柄网格_Y;
static std::vector<S_网格包> g移动变换手柄网格_Z;
static std::vector<S_网格包> g旋转变换手柄网格_X;
static std::vector<S_网格包> g旋转变换手柄网格_Y;
static std::vector<S_网格包> g旋转变换手柄网格_Z;
static std::vector<S_网格包> g缩放变换手柄网格_X;
static std::vector<S_网格包> g缩放变换手柄网格_Y;
static std::vector<S_网格包> g缩放变换手柄网格_Z;

static S_网格包 g锁定轴线[3] = {};

static E_变换 g_当前手柄变换类型 = E_变换::e_变换_None;

S_物体* f_辅助物体_创建移动变换手柄(S_设备环境& ctx) {
	auto ob = f_ob_创建(ctx, E_物体类型::t_网格物体);
	ob->m_深度偏移 = 10;

	if (g移动变换手柄网格.empty()) {
		f_ob_set数据槽数量(ob, 11);
		auto& 轴线X = f_ob_setData<S_ConstPush_Mesh_Line>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 0);
		auto& 轴线Y = f_ob_setData<S_ConstPush_Mesh_Line>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 1);
		auto& 轴线Z = f_ob_setData<S_ConstPush_Mesh_Line>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 2);

		auto& 箭头X = f_ob_setData<S_ConstPush_Mesh_Face>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 3);
		auto& 箭头Y = f_ob_setData<S_ConstPush_Mesh_Face>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 4);
		auto& 箭头Z = f_ob_setData<S_ConstPush_Mesh_Face>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 5);
		auto& 中心点 = f_ob_setData<S_ConstPush_Mesh_Point>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 6);
		auto& 移动中心圈 = f_ob_setData<S_ConstPush_Mesh_Line>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 7);

		auto& 平面XY = f_ob_setData<S_ConstPush_Mesh_Face>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 8);
		auto& 平面XZ = f_ob_setData<S_ConstPush_Mesh_Face>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 9);
		auto& 平面YZ = f_ob_setData<S_ConstPush_Mesh_Face>(ob, f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), 10);


		
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal], 0);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal], 1);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal], 2);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal], 3);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal], 4);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal], 5);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal], 6);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal], 7);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal], 8);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal], 9);
		f_ob_set材质(ob, ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal], 10);


		轴线X.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		轴线X.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
		轴线X.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
		轴线X.m_Mesh->m_线宽				= 3;
		f_df_推送常量<S_ConstPush_Mesh_Line>(轴线X.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);
		轴线Y.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		轴线Y.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
		轴线Y.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
		轴线Y.m_Mesh->m_线宽				= 3;
		f_df_推送常量<S_ConstPush_Mesh_Line>(轴线Y.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
		轴线Z.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		轴线Z.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
		轴线Z.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
		轴线Z.m_Mesh->m_线宽				= 3;
		f_df_推送常量<S_ConstPush_Mesh_Line>(轴线Z.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);

		箭头X.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		箭头X.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
		f_df_推送常量<S_ConstPush_Mesh_Face>(箭头X.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);
		箭头Y.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		箭头Y.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
		f_df_推送常量<S_ConstPush_Mesh_Face>(箭头Y.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
		箭头Z.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		箭头Z.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
		f_df_推送常量<S_ConstPush_Mesh_Face>(箭头Z.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);

		中心点.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
		中心点.m_Mesh->mf_参数设置回调		= f_变换手柄_点参数修改;


		移动中心圈.m_Mesh->m_绘制类型		= S_元素绘制类型::e_绘制类型_索引;
		移动中心圈.m_Mesh->mf_参数设置回调	= f_变换手柄_朝向视口线参数修改;
		移动中心圈.m_Mesh->m_顶点变换模式	= DEF_3DTranform_LookAt;
		移动中心圈.m_Mesh->m_片源着色模式	= DEF_3DShaderType_PerObColor;
		移动中心圈.m_Mesh->m_线宽 = 3;
		f_df_推送常量<S_ConstPush_Mesh_Line>(移动中心圈.m_常量推送).m_Ob_Color = f_PackData4X8(S_RGBA8UI{ 140, 140, 140, 255 });


		平面XY.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		平面XY.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
		f_df_推送常量<S_ConstPush_Mesh_Face>(平面XY.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);

		平面XZ.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		平面XZ.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
		f_df_推送常量<S_ConstPush_Mesh_Face>(平面XZ.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);

		平面YZ.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
		平面YZ.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
		f_df_推送常量<S_ConstPush_Mesh_Face>(平面YZ.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);



		std::vector<S_VNTC> 顶点;
		std::vector<uint32> 索引;

		索引.emplace_back(0);
		索引.emplace_back(1);
		顶点.push_back({{0.2,0.0,0.0}, {}, {0,0,R顶点颜色}});
		顶点.push_back({{1.0,0.0,0.0}, {}, {0,0,R顶点颜色}});
		f_me_fill顶点(轴线X.m_Mesh, 顶点);
		f_me_fill索引(轴线X.m_Mesh, 索引);

		顶点.clear();
		顶点.push_back({{0.0,0.2,0.0}, {}, {0,0,G顶点颜色}});
		顶点.push_back({{0.0,1.0,0.0}, {}, {0,0,G顶点颜色}});
		f_me_fill顶点(轴线Y.m_Mesh, 顶点);
		f_me_fill索引(轴线Y.m_Mesh, 索引);

		顶点.clear();
		顶点.push_back({{0.0,0.0,0.2}, {}, {0,0,B顶点颜色}});
		顶点.push_back({{0.0,0.0,1.0}, {}, {0,0,B顶点颜色}});
		f_me_fill顶点(轴线Z.m_Mesh, 顶点);
		f_me_fill索引(轴线Z.m_Mesh, 索引);




		顶点.clear();
		索引.clear();
		f_graph_锥形(顶点, 索引, {0.08f,0.35,6}, {0,0,0}, S_主题颜色::uic_R, E_轴向::e_X, true);
		顶点 *= _Vec3(0.7);
		顶点 += vec3{1.0,0.0,0.0};
		f_me_fill顶点(箭头X.m_Mesh, 顶点);
		f_me_fill索引(箭头X.m_Mesh, 索引);

		顶点.clear();
		索引.clear();
		f_graph_锥形(顶点, 索引, {0.08f,0.35,6}, {0,0,0}, S_主题颜色::uic_G, E_轴向::e_Y, true);
		顶点 *= _Vec3(0.7);
		顶点 += vec3{0.0,1.0,0.0};
		f_me_fill顶点(箭头Y.m_Mesh, 顶点);
		f_me_fill索引(箭头Y.m_Mesh, 索引);

		顶点.clear();
		索引.clear();
		f_graph_锥形(顶点, 索引, {0.08f,0.35,6}, {0,0,0}, S_主题颜色::uic_B, E_轴向::e_Z, true);
		顶点 *= _Vec3(0.7);
		顶点 += vec3{0.0,0.0,1.0};
		f_me_fill顶点(箭头Z.m_Mesh, 顶点);
		f_me_fill索引(箭头Z.m_Mesh, 索引);



		f_me_fill顶点(中心点.m_Mesh, { {{},{},{0,0,C顶点颜色}} });


		顶点.clear();
		索引.clear();
		f_graph_圆(顶点, 索引, 0.2, {}, {125,125,125,255});
		f_me_fill顶点(移动中心圈.m_Mesh, 顶点);
		f_me_fill索引(移动中心圈.m_Mesh, 索引);




		顶点.clear();
		索引.clear();
		f_graph_平面(顶点, 索引, {1,1}, {0.2,0.2}, {0.6,0.6}, S_主题颜色::uic_RG, E_轴向::e_Z, true);
		索引 = f_polygon_三角化(顶点, 索引);
		f_me_fill顶点(平面XY.m_Mesh, 顶点);
		f_me_fill索引(平面XY.m_Mesh, 索引);

		顶点.clear();
		索引.clear();
		f_graph_平面(顶点, 索引, {1,1}, {0.2,0.2}, {0.6,0.6}, S_主题颜色::uic_RB, E_轴向::e_Y, true);
		索引 = f_polygon_三角化(顶点, 索引);
		f_me_fill顶点(平面XZ.m_Mesh, 顶点);
		f_me_fill索引(平面XZ.m_Mesh, 索引);

		顶点.clear();
		索引.clear();
		f_graph_平面(顶点, 索引, {1,1}, {0.2,0.2}, {0.6,0.6}, S_主题颜色::uic_GB, E_轴向::e_X, true);
		索引 = f_polygon_三角化(顶点, 索引);
		f_me_fill顶点(平面YZ.m_Mesh, 顶点);
		f_me_fill索引(平面YZ.m_Mesh, 索引);


		g移动变换手柄网格.push_back(轴线X);
		g移动变换手柄网格.push_back(轴线Y);
		g移动变换手柄网格.push_back(轴线Z);
		g移动变换手柄网格.push_back(箭头X);
		g移动变换手柄网格.push_back(箭头Y);
		g移动变换手柄网格.push_back(箭头Z);
		g移动变换手柄网格.push_back(中心点);
		g移动变换手柄网格.push_back(移动中心圈);
		g移动变换手柄网格.push_back(平面XY);
		g移动变换手柄网格.push_back(平面XZ);
		g移动变换手柄网格.push_back(平面YZ);

		g移动变换手柄网格_X.push_back(中心点);
		g移动变换手柄网格_X.push_back(轴线X);
		g移动变换手柄网格_X.push_back(箭头X);
		
		g移动变换手柄网格_Y.push_back(中心点);
		g移动变换手柄网格_Y.push_back(轴线Y);
		g移动变换手柄网格_Y.push_back(箭头Y);

		g移动变换手柄网格_Z.push_back(中心点);
		g移动变换手柄网格_Z.push_back(轴线Z);
		g移动变换手柄网格_Z.push_back(箭头Z);



		{
			auto line_x = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
			auto line_y = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
			auto line_z = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);

			line_x.m_Mesh->m_绘制类型		= S_元素绘制类型::e_绘制类型_索引;
			line_x.m_Mesh->mf_参数设置回调	= f_变换手柄_线参数修改;
			line_x.m_Mesh->m_顶点变换模式	= DEF_3DTranform_Normal;
			line_x.m_Mesh->m_片源着色模式	= DEF_3DShaderType_PerObColor;
			line_x.m_Mesh->m_线宽 = 0.5;
			f_df_推送常量<S_ConstPush_Mesh_Line>(line_x.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);
			line_y.m_Mesh->m_绘制类型		= S_元素绘制类型::e_绘制类型_索引;
			line_y.m_Mesh->mf_参数设置回调	= f_变换手柄_线参数修改;
			line_y.m_Mesh->m_顶点变换模式	= DEF_3DTranform_Normal;
			line_y.m_Mesh->m_片源着色模式	= DEF_3DShaderType_PerObColor;
			line_y.m_Mesh->m_线宽 = 0.5;
			f_df_推送常量<S_ConstPush_Mesh_Line>(line_y.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
			line_z.m_Mesh->m_绘制类型		= S_元素绘制类型::e_绘制类型_索引;
			line_z.m_Mesh->mf_参数设置回调	= f_变换手柄_线参数修改;
			line_z.m_Mesh->m_顶点变换模式	= DEF_3DTranform_Normal;
			line_z.m_Mesh->m_片源着色模式	= DEF_3DShaderType_PerObColor;
			line_z.m_Mesh->m_线宽 = 0.5;
			f_df_推送常量<S_ConstPush_Mesh_Line>(line_z.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);


			索引.emplace_back(0);
			索引.emplace_back(1);
			顶点.clear();
			顶点.push_back({{-1.0e+4,0.0,0.0}, {}, {0,0,R顶点颜色}});
			顶点.push_back({{1.0e+4,0.0,0.0}, {}, {0,0,R顶点颜色}});
			f_me_fill顶点(line_x.m_Mesh, 顶点);
			f_me_fill索引(line_x.m_Mesh, 索引);

			顶点.clear();
			顶点.push_back({{0.0, -1.0e+4,0.0}, {}, {0,0,G顶点颜色}});
			顶点.push_back({{0.0, 1.0e+4,0.0,}, {}, {0,0,G顶点颜色}});
			f_me_fill顶点(line_y.m_Mesh, 顶点);
			f_me_fill索引(line_y.m_Mesh, 索引);

			顶点.clear();
			顶点.push_back({{0.0,0.0,-1.0e+4}, {}, {0,0,B顶点颜色}});
			顶点.push_back({{0.0,0.0,1.0e+4}, {}, {0,0,B顶点颜色}});
			f_me_fill顶点(line_z.m_Mesh, 顶点);
			f_me_fill索引(line_z.m_Mesh, 索引);

			g锁定轴线[0] = (line_x);
			g锁定轴线[1] = (line_y);
			g锁定轴线[2] = (line_z);

			g移动变换手柄网格_X.push_back(line_x);
			g移动变换手柄网格_Y.push_back(line_y);
			g移动变换手柄网格_Z.push_back(line_z);
		}
		

	}
	else {
		f_辅助物体_切换变换手柄类型(ob, E_变换::e_移动);
	}

	g_当前手柄变换类型 = E_变换::e_移动;
	return ob;
}

S_物体* f_辅助物体_创建旋转变换手柄(S_设备环境& ctx) {
	auto x = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto y = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto z = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto c = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto p = f_ob_创建网格包<S_ConstPush_Mesh_Point>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal]);
	
	x.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	x.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
	x.m_Mesh->m_片源着色模式		= DEF_3DShaderType_FronWeight;
	x.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(x.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);
	y.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	y.m_Mesh->m_片源着色模式		= DEF_3DShaderType_FronWeight;
	y.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
	y.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(y.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
	z.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	z.m_Mesh->m_片源着色模式		= DEF_3DShaderType_FronWeight;
	z.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
	z.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(z.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);
	c.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	c.m_Mesh->m_顶点变换模式		= DEF_3DTranform_LookAt;
	c.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
	c.m_Mesh->mf_参数设置回调		= f_变换手柄_朝向视口线参数修改;
	c.m_Mesh->m_线宽				= 1.6;
	f_df_推送常量<S_ConstPush_Mesh_Line>(c.m_常量推送).m_Ob_Color = f_PackData4X8({128,128,128,255});

	p.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
	p.m_Mesh->mf_参数设置回调		= f_变换手柄_点参数修改;
	f_df_推送常量<S_ConstPush_Mesh_Point>(c.m_常量推送).m_Ob_Color = f_PackData4X8({190,190,190,255});
	


	std::vector<S_VNTC> 顶点;
	std::vector<uint32> 索引;
	f_graph_圆(顶点, 索引, 1, {}, S_主题颜色::uic_R, E_轴向::e_X);
	for(auto& e : 顶点) e.normal = e.vert;
	f_me_fill顶点(x.m_Mesh, 顶点);
	f_me_fill索引(x.m_Mesh, 索引);

	顶点.clear();
	索引.clear();
	f_graph_圆(顶点, 索引, 1, {}, S_主题颜色::uic_G, E_轴向::e_Y);
	for(auto& e : 顶点) e.normal = e.vert;
	f_me_fill顶点(y.m_Mesh, 顶点);
	f_me_fill索引(y.m_Mesh, 索引);

	顶点.clear();
	索引.clear();
	f_graph_圆(顶点, 索引, 1, {}, S_主题颜色::uic_B, E_轴向::e_Z);
	for(auto& e : 顶点) e.normal = e.vert;
	f_me_fill顶点(z.m_Mesh, 顶点);
	f_me_fill索引(z.m_Mesh, 索引);

	顶点.clear();
	索引.clear();
	f_graph_圆(顶点, 索引, 1.3, {}, {150,150,150,255}, E_轴向::e_Z);
	f_me_fill顶点(c.m_Mesh, 顶点);
	f_me_fill索引(c.m_Mesh, 索引);

	f_me_fill顶点(p.m_Mesh, { {{},{},{0,0,C顶点颜色}} });



	g旋转变换手柄网格.push_back(x);
	g旋转变换手柄网格.push_back(y);
	g旋转变换手柄网格.push_back(z);
	g旋转变换手柄网格.push_back(c);
	g旋转变换手柄网格.push_back(p);
	
	g旋转变换手柄网格_X.push_back(p);
	g旋转变换手柄网格_X.push_back(x);
	g旋转变换手柄网格_Y.push_back(p);
	g旋转变换手柄网格_Y.push_back(y);
	g旋转变换手柄网格_Z.push_back(p);
	g旋转变换手柄网格_Z.push_back(z);

	g旋转变换手柄网格_X.push_back(g锁定轴线[0]);
	g旋转变换手柄网格_Y.push_back(g锁定轴线[1]);
	g旋转变换手柄网格_Z.push_back(g锁定轴线[2]);
	//f_ob_set安装网格()
	return nullptr;
}


static void f_缩放变换手柄_端点参数修改(S_Object* ob, S_网格包& me, uint32 多维子元素) {
	S_物体* em = dynamic_cast<S_物体*>(ob);
	auto& push = f_df_推送常量<S_ConstPush_Mesh_Point>(me.m_常量推送);
	push.m_Offset_Tranform = em->m_变换矩阵.m_Mem.m_偏移;
	push.m_Ob_ShaderType = f_glsl_Build_ShaderType(DEF_3DShaderType_PerObCirclePoint, DEF_3DTranform_Normal);
	push.m_PointSize = DEF_手柄端点大小 * me.m_Mesh->m_线宽;
}

S_物体* f_辅助物体_创建缩放变换手柄(S_设备环境& ctx) {
	auto p = f_ob_创建网格包<S_ConstPush_Mesh_Point>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal]);
	auto x = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto y = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto z = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto xp = f_ob_创建网格包<S_ConstPush_Mesh_Point>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal]);
	auto yp = f_ob_创建网格包<S_ConstPush_Mesh_Point>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal]);
	auto zp = f_ob_创建网格包<S_ConstPush_Mesh_Point>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_点[E_图层混合模式::e_Normal]);
	auto c = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	auto cc = f_ob_创建网格包<S_ConstPush_Mesh_Line>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_线[E_图层混合模式::e_Normal]);
	
	auto 平面XY = f_ob_创建网格包<S_ConstPush_Mesh_Face>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal]);
	auto 平面XZ = f_ob_创建网格包<S_ConstPush_Mesh_Face>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal]);
	auto 平面YZ = f_ob_创建网格包<S_ConstPush_Mesh_Face>(f_surface_创建网格对象(ctx, E_网格数据枚举::e_Mesh_Vulkan), ctx.m_绘图环境->m_3D渲染管线->m_管线_面[E_图层混合模式::e_Normal]);



	p.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
	p.m_Mesh->mf_参数设置回调		= f_变换手柄_点参数修改;
	f_df_推送常量<S_ConstPush_Mesh_Point>(c.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_焦点);

	x.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	x.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
	x.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
	x.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(x.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);
	y.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	y.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
	y.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
	y.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(y.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
	z.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	z.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
	z.m_Mesh->mf_参数设置回调		= f_变换手柄_线参数修改;
	z.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(z.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);

	xp.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
	xp.m_Mesh->mf_参数设置回调		= f_缩放变换手柄_端点参数修改;
	xp.m_Mesh->m_片源着色模式		= DEF_FS_ShaderType_CirclePoint;
	xp.m_Mesh->m_线宽				= 1;
	f_df_推送常量<S_ConstPush_Mesh_Line>(xp.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);
	yp.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
	yp.m_Mesh->m_片源着色模式		= DEF_FS_ShaderType_CirclePoint;
	yp.m_Mesh->mf_参数设置回调		= f_缩放变换手柄_端点参数修改;
	yp.m_Mesh->m_线宽				= 1;
	f_df_推送常量<S_ConstPush_Mesh_Line>(yp.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
	zp.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_序列;
	zp.m_Mesh->m_片源着色模式		= DEF_FS_ShaderType_CirclePoint;
	zp.m_Mesh->mf_参数设置回调		= f_缩放变换手柄_端点参数修改;
	zp.m_Mesh->m_线宽				= 1;
	f_df_推送常量<S_ConstPush_Mesh_Line>(zp.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);

	c.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	c.m_Mesh->m_顶点变换模式		= DEF_3DTranform_LookAt;
	c.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
	c.m_Mesh->mf_参数设置回调		= f_变换手柄_朝向视口线参数修改;
	c.m_Mesh->m_线宽				= 1.6;
	f_df_推送常量<S_ConstPush_Mesh_Line>(c.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_C);

	cc.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	cc.m_Mesh->m_顶点变换模式		= DEF_3DTranform_LookAt;
	cc.m_Mesh->m_片源着色模式		= DEF_3DShaderType_PerObColor;
	cc.m_Mesh->mf_参数设置回调		= f_变换手柄_朝向视口线参数修改;
	cc.m_Mesh->m_线宽				= 3;
	f_df_推送常量<S_ConstPush_Mesh_Line>(cc.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_C);
	

	平面XY.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	平面XY.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
	f_df_推送常量<S_ConstPush_Mesh_Face>(平面XY.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_B);
	平面XZ.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	平面XZ.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
	f_df_推送常量<S_ConstPush_Mesh_Face>(平面XZ.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_G);
	平面YZ.m_Mesh->m_绘制类型			= S_元素绘制类型::e_绘制类型_索引;
	平面YZ.m_Mesh->mf_参数设置回调		= f_变换手柄_面参数修改;
	f_df_推送常量<S_ConstPush_Mesh_Face>(平面YZ.m_常量推送).m_Ob_Color = f_PackData4X8(S_主题颜色::uic_R);



	f_me_fill顶点(p.m_Mesh, { {{},{},{0,0,C顶点颜色}} });

	std::vector<S_VNTC> 顶点;
	std::vector<uint32> 索引;
	索引.emplace_back(0);
	索引.emplace_back(1);
	顶点.push_back({{0.2,0.0,0.0}, {}, {0,0,R顶点颜色}});
	顶点.push_back({{1.0,0.0,0.0}, {}, {0,0,R顶点颜色}});
	for(auto& e : 顶点) e.normal = e.vert;
	f_me_fill顶点(x.m_Mesh, 顶点);
	f_me_fill索引(x.m_Mesh, 索引);

	顶点.clear();
	顶点.push_back({{0.0,0.2,0.0}, {}, {0,0,G顶点颜色}});
	顶点.push_back({{0.0,1.0,0.0}, {}, {0,0,G顶点颜色}});
	for(auto& e : 顶点) e.normal = e.vert;
	f_me_fill顶点(y.m_Mesh, 顶点);
	f_me_fill索引(y.m_Mesh, 索引);

	顶点.clear();
	顶点.push_back({{0.0,0.0,0.2}, {}, {0,0,B顶点颜色}});
	顶点.push_back({{0.0,0.0,1.0}, {}, {0,0,B顶点颜色}});
	for(auto& e : 顶点) e.normal = e.vert;
	f_me_fill顶点(z.m_Mesh, 顶点);
	f_me_fill索引(z.m_Mesh, 索引);


	f_me_fill顶点(xp.m_Mesh, { {{1.0,0.0,0.0},{},{0,0,R顶点颜色}} });
	f_me_fill顶点(yp.m_Mesh, { {{0.0,1.0,0.0},{},{0,0,G顶点颜色}} });
	f_me_fill顶点(zp.m_Mesh, { {{0.0,0.0,1.0},{},{0,0,B顶点颜色}} });

	顶点.clear();
	索引.clear();
	f_graph_圆(顶点, 索引, 1.3, {}, {150,150,150,255}, E_轴向::e_Z);
	f_me_fill顶点(c.m_Mesh, 顶点);
	f_me_fill索引(c.m_Mesh, 索引);

	顶点.clear();
	索引.clear();
	f_graph_圆(顶点, 索引, 0.2, {}, {150,150,150,255}, E_轴向::e_Z);
	f_me_fill顶点(cc.m_Mesh, 顶点);
	f_me_fill索引(cc.m_Mesh, 索引);


	顶点.clear();
	索引.clear();
	f_graph_平面(顶点, 索引, {1,1}, {0.2,0.2}, {0.6,0.6}, S_主题颜色::uic_RG, E_轴向::e_Z, true);
	索引 = f_polygon_三角化(顶点, 索引);
	f_me_fill顶点(平面XY.m_Mesh, 顶点);
	f_me_fill索引(平面XY.m_Mesh, 索引);

	顶点.clear();
	索引.clear();
	f_graph_平面(顶点, 索引, {1,1}, {0.2,0.2}, {0.6,0.6}, S_主题颜色::uic_RB, E_轴向::e_Y, true);
	索引 = f_polygon_三角化(顶点, 索引);
	f_me_fill顶点(平面XZ.m_Mesh, 顶点);
	f_me_fill索引(平面XZ.m_Mesh, 索引);

	顶点.clear();
	索引.clear();
	f_graph_平面(顶点, 索引, {1,1}, {0.2,0.2}, {0.6,0.6}, S_主题颜色::uic_GB, E_轴向::e_X, true);
	索引 = f_polygon_三角化(顶点, 索引);
	f_me_fill顶点(平面YZ.m_Mesh, 顶点);
	f_me_fill索引(平面YZ.m_Mesh, 索引);



	g缩放变换手柄网格.push_back(p);
	g缩放变换手柄网格.push_back(x);
	g缩放变换手柄网格.push_back(y);
	g缩放变换手柄网格.push_back(z);
	g缩放变换手柄网格.push_back(xp);
	g缩放变换手柄网格.push_back(yp);
	g缩放变换手柄网格.push_back(zp);
	g缩放变换手柄网格.push_back(c);
	g缩放变换手柄网格.push_back(cc);
	g缩放变换手柄网格.push_back(平面XY);
	g缩放变换手柄网格.push_back(平面XZ);
	g缩放变换手柄网格.push_back(平面YZ);
	
	g缩放变换手柄网格_X.push_back(p);
	g缩放变换手柄网格_X.push_back(x);
	g缩放变换手柄网格_X.push_back(xp);
	g缩放变换手柄网格_Y.push_back(p);
	g缩放变换手柄网格_Y.push_back(y);
	g缩放变换手柄网格_Y.push_back(yp);
	g缩放变换手柄网格_Z.push_back(p);
	g缩放变换手柄网格_Z.push_back(z);
	g缩放变换手柄网格_Z.push_back(zp);

	g缩放变换手柄网格_X.push_back(g锁定轴线[0]);
	g缩放变换手柄网格_Y.push_back(g锁定轴线[1]);
	g缩放变换手柄网格_Z.push_back(g锁定轴线[2]);
	return nullptr;
}


void f_辅助物体_切换变换手柄类型(S_物体* ob, E_变换 变换类型) {
	
	switch (变换类型) {
		case E_变换::e_移动: {
			f_ob_set安装网格(ob, g移动变换手柄网格);
			break;
		}
		case E_变换::e_旋转: {
			f_ob_set安装网格(ob, g旋转变换手柄网格);
			break;
		}
		case E_变换::e_缩放: {
			f_ob_set安装网格(ob, g缩放变换手柄网格);
			break;
		}
		default:
			break;
	}

	g_当前手柄变换类型 = 变换类型;
	S_框架::g_物体变换方式 = 变换类型;
}

void f_辅助物体_切换变换手柄轴显示(S_物体* ob, E_轴向 轴向) {
	switch (g_当前手柄变换类型) {
		case E_变换::e_移动: {
			switch (轴向) {
				case E_轴向::e_X: f_ob_set安装网格(ob, g移动变换手柄网格_X); break;
				case E_轴向::e_Y: f_ob_set安装网格(ob, g移动变换手柄网格_Y); break;
				case E_轴向::e_Z: f_ob_set安装网格(ob, g移动变换手柄网格_Z); break;
				default:
					f_ob_set安装网格(ob, g移动变换手柄网格);
					break;
			}
			break;
		}
		case E_变换::e_旋转: {
			switch (轴向) {
				case E_轴向::e_X: {
					for (auto& e : g旋转变换手柄网格_X) {
						e.m_Mesh->m_片源着色模式 = DEF_3DShaderType_PerObColor;
					}
					f_ob_set安装网格(ob, g旋转变换手柄网格_X); 
					break;
				}
				case E_轴向::e_Y: {
					for (auto& e : g旋转变换手柄网格_Y) {
						e.m_Mesh->m_片源着色模式 = DEF_3DShaderType_PerObColor;
					}
					f_ob_set安装网格(ob, g旋转变换手柄网格_Y); 
					break;
				}
				case E_轴向::e_Z: {
					for (auto& e : g旋转变换手柄网格_Z) {
						e.m_Mesh->m_片源着色模式 = DEF_3DShaderType_PerObColor;
					}
					f_ob_set安装网格(ob, g旋转变换手柄网格_Z); 
					break;
				}
				default:
					for (uint32 i = 0; i < 3; ++i) {
						g旋转变换手柄网格[i].m_Mesh->m_片源着色模式 = DEF_3DShaderType_FronWeight;
					}
					f_ob_set安装网格(ob, g旋转变换手柄网格);
					break;
			}
			break;
		}
		case E_变换::e_缩放: {
			switch (轴向) {
				case E_轴向::e_X: f_ob_set安装网格(ob, g缩放变换手柄网格_X); break;
				case E_轴向::e_Y: f_ob_set安装网格(ob, g缩放变换手柄网格_Y); break;
				case E_轴向::e_Z: f_ob_set安装网格(ob, g缩放变换手柄网格_Z); break;
				default:
					f_ob_set安装网格(ob, g缩放变换手柄网格);
					break;
			}
			break;
		}
		default:
			break;
	}
	
}

void f_辅助物体_变换手柄缩放(S_物体* ob, const S_摄像机& camera, const S_Rect2Df& viewport) {
	vec3 眼睛位置 = f_camera_get眼睛位置(camera);
	vec3 视线向量 = f_camera_get视线向量(camera);
	
	if (camera.m_投影模式 == E_投影模式::e_透视) {
		vec3 物体位置 = ob->m_变换.position;

		vec4 p1 = f_graph_坐标构建平面(物体位置, 视线向量);
		float32 距离1 = fabs(f_graph_点到平面距离(眼睛位置, p1));
		float32 距离2 = length(物体位置 - 眼睛位置);

		auto mat1 = f_mat44_identity();
		mat1.m32 = 距离1;

		vec2 coord1 = f_Project空间坐标转屏幕(camera.m_相机投影矩阵, mat1, { 0, 0, 0 }, viewport);
		vec2 coord2 = f_Project空间坐标转屏幕(camera.m_相机投影矩阵, mat1, { 1, 1, 0 }, viewport);
		coord2 -= coord1;

		auto mat2 = f_mat44_identity();
		mat2.m32 = 距离2;
		vec2 coord3 = f_Project空间坐标转屏幕(camera.m_相机投影矩阵, mat2, { 0, 0, 0 }, viewport);
		vec2 coord4 = f_Project空间坐标转屏幕(camera.m_相机投影矩阵, mat2, { 1, 1, 0 }, viewport);
		coord4 -= coord3;

		//std::cout<<"表面倾斜角度 = "<< coord4.x / coord2.x << " " << coord2.y << std::endl;
		float32 距离 = 距离2 * (coord4.x / coord2.x);
		f_ob_setScale(ob, _Vec3(距离* 0.1) );
	}
	else {
		float32 距离 = camera.m_视距;
		f_ob_setScale(ob, _Vec3(距离* 0.1) );
	}
	
}



